home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2001 January / january_2001.iso / intercd / root / ^4Developers / VB / visbasdb / VBDB / VBDB Code / VB5 Code / Class 6 / Example6-1.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-21  |  7.9 KB  |  268 lines

  1. VERSION 5.00
  2. Begin VB.Form frmMailingList 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Mailing List Application"
  5.    ClientHeight    =   3375
  6.    ClientLeft      =   45
  7.    ClientTop       =   345
  8.    ClientWidth     =   7875
  9.    LinkTopic       =   "Form1"
  10.    MaxButton       =   0   'False
  11.    MinButton       =   0   'False
  12.    ScaleHeight     =   3375
  13.    ScaleWidth      =   7875
  14.    StartUpPosition =   3  'Windows Default
  15.    Begin VB.Frame fraTime 
  16.       Caption         =   "Elapsed Time"
  17.       Height          =   3135
  18.       Left            =   5760
  19.       TabIndex        =   7
  20.       Top             =   120
  21.       Width           =   2055
  22.       Begin VB.Timer timSeconds 
  23.          Enabled         =   0   'False
  24.          Interval        =   1000
  25.          Left            =   120
  26.          Top             =   840
  27.       End
  28.       Begin VB.CommandButton cmdExit 
  29.          Caption         =   "E&xit"
  30.          Height          =   495
  31.          Left            =   480
  32.          TabIndex        =   17
  33.          Top             =   2520
  34.          Width           =   1215
  35.       End
  36.       Begin VB.CommandButton cmdPause 
  37.          Caption         =   "&Pause"
  38.          Enabled         =   0   'False
  39.          Height          =   495
  40.          Left            =   480
  41.          TabIndex        =   16
  42.          Top             =   1920
  43.          Width           =   1215
  44.       End
  45.       Begin VB.CommandButton cmdStart 
  46.          Caption         =   "&Start"
  47.          Height          =   495
  48.          Left            =   480
  49.          TabIndex        =   15
  50.          Top             =   1320
  51.          Width           =   1215
  52.       End
  53.       Begin VB.Label lblElapsedTime 
  54.          Alignment       =   2  'Center
  55.          BackColor       =   &H00FFFFFF&
  56.          BorderStyle     =   1  'Fixed Single
  57.          Caption         =   "00:00:00"
  58.          BeginProperty Font 
  59.             Name            =   "MS Sans Serif"
  60.             Size            =   13.5
  61.             Charset         =   0
  62.             Weight          =   700
  63.             Underline       =   0   'False
  64.             Italic          =   0   'False
  65.             Strikethrough   =   0   'False
  66.          EndProperty
  67.          Height          =   495
  68.          Left            =   240
  69.          TabIndex        =   14
  70.          Top             =   360
  71.          Width           =   1575
  72.       End
  73.    End
  74.    Begin VB.Frame fraMail 
  75.       Caption         =   "Address Information"
  76.       Enabled         =   0   'False
  77.       Height          =   3135
  78.       Left            =   120
  79.       TabIndex        =   0
  80.       Top             =   120
  81.       Width           =   5535
  82.       Begin VB.TextBox txtInput 
  83.          Height          =   375
  84.          Index           =   4
  85.          Left            =   3960
  86.          TabIndex        =   5
  87.          Top             =   1800
  88.          Width           =   1455
  89.       End
  90.       Begin VB.TextBox txtInput 
  91.          Height          =   375
  92.          Index           =   3
  93.          Left            =   960
  94.          TabIndex        =   4
  95.          Top             =   1800
  96.          Width           =   2055
  97.       End
  98.       Begin VB.TextBox txtInput 
  99.          Height          =   375
  100.          Index           =   2
  101.          Left            =   960
  102.          TabIndex        =   3
  103.          Top             =   1320
  104.          Width           =   4455
  105.       End
  106.       Begin VB.TextBox txtInput 
  107.          Height          =   375
  108.          Index           =   1
  109.          Left            =   960
  110.          TabIndex        =   2
  111.          Top             =   840
  112.          Width           =   4455
  113.       End
  114.       Begin VB.TextBox txtInput 
  115.          Height          =   375
  116.          Index           =   0
  117.          Left            =   960
  118.          TabIndex        =   1
  119.          Top             =   360
  120.          Width           =   4455
  121.       End
  122.       Begin VB.CommandButton cmdClear 
  123.          Caption         =   "&Clear"
  124.          Height          =   495
  125.          Left            =   3120
  126.          TabIndex        =   13
  127.          Top             =   2400
  128.          Width           =   1215
  129.       End
  130.       Begin VB.CommandButton cmdAccept 
  131.          Caption         =   "&Accept"
  132.          Height          =   495
  133.          Left            =   1560
  134.          TabIndex        =   6
  135.          Top             =   2400
  136.          Width           =   1215
  137.       End
  138.       Begin VB.Label Label5 
  139.          Caption         =   "Zip"
  140.          Height          =   375
  141.          Left            =   3240
  142.          TabIndex        =   12
  143.          Top             =   1800
  144.          Width           =   1215
  145.       End
  146.       Begin VB.Label Label4 
  147.          Caption         =   "State"
  148.          Height          =   375
  149.          Left            =   120
  150.          TabIndex        =   11
  151.          Top             =   1800
  152.          Width           =   1215
  153.       End
  154.       Begin VB.Label Label3 
  155.          Caption         =   "City"
  156.          Height          =   375
  157.          Left            =   120
  158.          TabIndex        =   10
  159.          Top             =   1320
  160.          Width           =   1215
  161.       End
  162.       Begin VB.Label Label2 
  163.          Caption         =   "Address"
  164.          Height          =   375
  165.          Left            =   120
  166.          TabIndex        =   9
  167.          Top             =   840
  168.          Width           =   1215
  169.       End
  170.       Begin VB.Label Label1 
  171.          Caption         =   "Name"
  172.          Height          =   375
  173.          Left            =   120
  174.          TabIndex        =   8
  175.          Top             =   360
  176.          Width           =   1215
  177.       End
  178.    End
  179. Attribute VB_Name = "frmMailingList"
  180. Attribute VB_GlobalNameSpace = False
  181. Attribute VB_Creatable = False
  182. Attribute VB_PredeclaredId = True
  183. Attribute VB_Exposed = False
  184. Option Explicit
  185. Dim ElapsedTime As Variant
  186. Dim LastNow As Variant
  187. Private Sub cmdAccept_Click()
  188. Dim S As String, I As Integer
  189. 'Accept button clicked - form label and output in message box
  190. 'Make sure each text box has entry
  191. For I = 0 To 4
  192.   If txtInput(I).Text = "" Then
  193.     MsgBox "Each box must have an entry!", vbInformation + vbOKOnly, "Error"
  194.     Exit Sub
  195.   End If
  196. Next I
  197. S = txtInput(0).Text + vbCrLf + txtInput(1).Text + vbCrLf
  198. S = S + txtInput(2).Text + ", " + txtInput(3).Text + " " + txtInput(4).Text
  199. MsgBox S, vbOKOnly, "Mailing Label"
  200. Call cmdClear_Click
  201. End Sub
  202. Private Sub cmdClear_Click()
  203. Dim I As Integer
  204. 'Clear all text boxes
  205. For I = 0 To 4
  206.   txtInput(I).Text = ""
  207. Next I
  208. txtInput(0).SetFocus
  209. End Sub
  210. Private Sub cmdExit_Click()
  211. 'Exit button clicked
  212. End Sub
  213. Private Sub cmdPause_Click()
  214. 'Pause button clicked
  215. 'Disable pause button
  216. 'Enabled start and exit buttons
  217. cmdPause.Enabled = False
  218. cmdStart.Enabled = True
  219. cmdExit.Enabled = True
  220. 'Stop timer
  221. timSeconds.Enabled = False
  222. 'Disable editing frame
  223. fraMail.Enabled = False
  224. End Sub
  225. Private Sub cmdStart_Click()
  226. 'Start button clicked
  227. 'Disable start and exit buttons
  228. 'Enabled pause button
  229. cmdStart.Enabled = False
  230. cmdExit.Enabled = False
  231. cmdPause.Enabled = True
  232. 'Establish start time and start timer control
  233. LastNow = Now
  234. timSeconds.Enabled = True
  235. 'Enable mailing list frame
  236. fraMail.Enabled = True
  237. txtInput(0).SetFocus
  238. End Sub
  239. Private Sub Form_Load()
  240. ElapsedTime = 0
  241. End Sub
  242. Private Sub timSeconds_Timer()
  243. 'Increase elapsed time and display
  244. ElapsedTime = ElapsedTime + Now - LastNow
  245. lblElapsedTime.Caption = Format(ElapsedTime, "hh:mm:ss")
  246. LastNow = Now
  247. End Sub
  248. Private Sub txtInput_KeyPress(Index As Integer, KeyAscii As Integer)
  249. Dim NextIndex As Integer
  250. 'Check for return key
  251. If KeyAscii = vbKeyReturn Then
  252.   NextIndex = Index + 1
  253.   If NextIndex > 4 Then
  254.     cmdAccept.SetFocus
  255.   Else
  256.     txtInput(NextIndex).SetFocus
  257.   End If
  258. End If
  259. 'In Zip text box, make sure only numbers or backspace pressed
  260. If Index = 4 Then
  261.   If (KeyAscii >= Asc("0") And KeyAscii <= Asc("9")) Or KeyAscii = vbKeyBack Then
  262.     Exit Sub
  263.   Else
  264.     KeyAscii = 0
  265.   End If
  266. End If
  267. End Sub
  268.